home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS18.ADF / Progs / StarProbe / SPMAIN.C < prev    next >
C/C++ Source or Header  |  1989-01-27  |  3KB  |  106 lines

  1. /****************************************************************************
  2.  ***                                                                      ***
  3.  ***                     S T A R   P R O B E                              ***
  4.  ***                                                                      ***
  5.  ****************************************************************************/
  6. /*****
  7.  ***  This program performs a cursory mathematical analysis of a star's
  8.  ***  interior.
  9.  *****/
  10.  
  11.  
  12. /*****
  13.  *** Global functions & procedures
  14.  *****/
  15.  
  16. #include "stdio.h"
  17. #include "spproc.h"
  18.  
  19. /*****
  20.  *** Global variables
  21.  *****/
  22.  
  23. #include "spmac.h"
  24. #include "spint.h"
  25. #include "spflt.h"
  26.  
  27.  
  28. /****************************************************************************
  29.  ***                       M  A  I  N                                     ***
  30.  ****************************************************************************/
  31. main()
  32. {
  33.  initialize();
  34.  
  35.  set_boundary_conditions();
  36.  
  37.  report_global();
  38.  
  39.  evaluate();
  40.  
  41.  shutdown();
  42. }
  43.  
  44. /*****
  45.  *** B l o c k  T r a c e
  46.  *****/
  47.  
  48. FILE *pf;
  49.  
  50. void block_trace(proc,dir,str,val)
  51. {
  52.  if (dir==in) {
  53.    level++;
  54.    if (level>MAX_LEVELS)
  55.      assert_error(-1,(double)level,(double)MAX_LEVELS,0.0,0.0,0.0,0.0,0.0);
  56.    proc_stack[level] = proc;
  57.    if ((debug > 1) | (debug == 1 && proc_trace[proc]==1))
  58.      fprintf(pf,"Enter ** %d ** %s = %g\n",level,str,val);
  59.    }
  60.  else
  61.  if (dir==mid) {
  62.    if ((debug > 2) | (debug==1 && proc_trace[proc]==1))
  63.      fprintf(pf,"      ** %d ** %s = %g\n",level,str,val);
  64.    }
  65.  else
  66.  if (dir==out) {
  67.    if ((debug > 1) | (debug == 1 && proc_trace[proc]==1))
  68.      fprintf(pf,"Exit  ** %d ** %s = %g\n",level,str,val);
  69.    level--;
  70.    }
  71. }
  72.  
  73. /*****
  74.  *** A s s e r t   E r r o r
  75.  *****/
  76.  
  77. void assert_error(proc,var,val,m,p,t,l,r)
  78. int proc;
  79. double var,val,m,p,t,l,r;
  80. {
  81. int i;
  82.  
  83.   fprintf(stderr,"########################################################\n");
  84.   fprintf(stderr,"### Assertion error in proc %d (%g :: %g)\n",proc,var,val); 
  85.   fprintf(stderr,"########################################################\n");
  86.  
  87.   fprintf(stderr,"Procedure trace:");
  88.   for (i=0;i<=level;i++)
  89.     fprintf(stderr," %2d",(proc_stack[i]));
  90.   fprintf(stderr,"\n");
  91.  
  92.   fprintf(stderr,"Current parameters:\n");
  93.   fprintf(stderr,"  m = %g\n",m);
  94.   fprintf(stderr,"  p = %g\n",p);
  95.   fprintf(stderr,"  t = %g\n",t);
  96.   fprintf(stderr,"  l = %g\n",l);
  97.   fprintf(stderr,"  r = %g\n",r);
  98.  
  99.   report_results();
  100.  
  101.   fprintf(stderr,"########################################################\n");
  102.  
  103.   exit(1);
  104. }
  105.  
  106.